#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include "component.h"
#include <windows.h>

int main(int argc, char *argv[])
{
    qDebug() << "Application starting...";
    // Windows下设置异常处理
    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
    QApplication a(argc, argv);

    // 注册Component*类型
    qRegisterMetaType<Component*>("Component*");

    try {
        MainWindow w;
        qDebug() << "MainWindow created successfully";
        w.show();
        return a.exec();
    } catch (const std::exception& e) {
        qCritical() << "Exception:" << e.what();
    } catch (...) {
        qCritical() << "Unknown exception occurred";
    }

    return -1;
}
